package org.rency.crawler.fetch.handler.impl;

import java.util.List;
import javax.annotation.Resource;
import org.rency.crawler.common.exception.CrawlerException;
import org.rency.crawler.domain.state.FetchStatus;
import org.rency.crawler.fetch.handler.AbstractFetchHandler;
import org.rency.crawler.fetch.helper.FetchCarrier;
import org.rency.crawler.fetch.service.grade.GradeService;
import org.springframework.stereotype.Component;

/**
 * 名称:FetchWeightHandler
 * 描述:${TODO}
 *
 * @author:rency
 * @version:V1.0.0
 * @JDK 1.8
 * @since 2017/11/22 22:19
 */
@Component
public class FetchWeightHandler extends AbstractFetchHandler{

  @Resource(name = "gradeServices")
  private List<GradeService> gradeServices;

  @Override
  protected String getHandlerName() {
    return "权重计算";
  }

  @Override
  protected void onHandler(FetchCarrier carrier) throws CrawlerException {
    for(GradeService gradeService : this.gradeServices){
      gradeService.grade(carrier);
    }
    carrier.getFetchState().setFsStatus(FetchStatus.SUCCESS);
  }
}
